﻿using Communergy.Logic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Communergy.NationalGridDataServices;
using Communergy.UnitTesting;


namespace CommunergyLogicTests
{
    
    
    /// <summary>
    ///This is a test class for NationalNationalGridDataHelperTest and is intended
    ///to contain all NationalNationalGridDataHelperTest Unit Tests
    ///</summary>
    [TestClass()]
    public class NationalNationalGridDataHelperTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion




        /// <summary>
        ///A test for AddLiveCarbonIntensityToDatabase
        ///</summary>
        [TestMethod()]
        public void CreateLiveCarbonIntensityTest_StartDateTime()
        {
            var expectedValue = UnitTestHelper.RandomDateTime();
            electricityCO2Item baseObject = new electricityCO2Item();
            baseObject.startDateGMT = expectedValue;
            baseObject.hhRollingMean = new electricityCO2ItemHhRollingMean();
            var liveCarbonIntensity = NationalGridDataHelper.CreateLiveCarbonIntensity(baseObject);
            Assert.AreEqual(expectedValue, liveCarbonIntensity.lc_startDateTime.Value);
        }

        [TestMethod()]
        public void CreateLiveCarbonIntensityTest_EndDateTime()
        {
            var expectedValue = UnitTestHelper.RandomDateTime();
            electricityCO2Item baseObject = new electricityCO2Item();
            baseObject.endDateGMT = expectedValue;
            baseObject.hhRollingMean = new electricityCO2ItemHhRollingMean();
            var liveCarbonIntensity = NationalGridDataHelper.CreateLiveCarbonIntensity(baseObject);
            Assert.AreEqual(expectedValue, liveCarbonIntensity.lc_endDateTime.Value);
        }

        [TestMethod()]
        public void CreateLiveCarbonIntensityTest_Intensity()
        {
            var expectedValue = ((decimal)UnitTestHelper.RandomInt(1, 100000) / 100000);
            electricityCO2Item baseObject = new electricityCO2Item();
            baseObject.amount = expectedValue;
            baseObject.hhRollingMean = new electricityCO2ItemHhRollingMean();
            var liveCarbonIntensity = NationalGridDataHelper.CreateLiveCarbonIntensity(baseObject);
            Assert.AreEqual(expectedValue, liveCarbonIntensity.lc_carbonIntensity);
        }



        [TestMethod()]
        public void CreateLiveCarbonIntensityTest_RollingMean_StartDateTime()
        {
            var expectedValue = UnitTestHelper.RandomDateTime();
            electricityCO2Item baseObject = new electricityCO2Item();

            baseObject.hhRollingMean = new electricityCO2ItemHhRollingMean();
            baseObject.hhRollingMean.startDateGMT = expectedValue;
            var liveCarbonIntensity = NationalGridDataHelper.CreateLiveCarbonIntensity(baseObject);
            Assert.AreEqual(expectedValue, liveCarbonIntensity.lc_rollingMeanStartDateTime);
        }

        [TestMethod()]
        public void CreateLiveCarbonIntensityTest_RollingMean_EndDateTime()
        {
            var expectedValue = UnitTestHelper.RandomDateTime();
            electricityCO2Item baseObject = new electricityCO2Item();

            baseObject.hhRollingMean = new electricityCO2ItemHhRollingMean();
            baseObject.hhRollingMean.endDateGMT = expectedValue;
            var liveCarbonIntensity = NationalGridDataHelper.CreateLiveCarbonIntensity(baseObject);
            Assert.AreEqual(expectedValue, liveCarbonIntensity.lc_rollingMeanEndDateTime);
        }

        [TestMethod()]
        public void CreateLiveCarbonIntensityTest_RollingMean_Intensity()
        {
            var expectedValue = ((decimal)UnitTestHelper.RandomInt(1, 100000) / 100000);
            electricityCO2Item baseObject = new electricityCO2Item();

            baseObject.hhRollingMean = new electricityCO2ItemHhRollingMean();
            baseObject.hhRollingMean.value = expectedValue;
            var liveCarbonIntensity = NationalGridDataHelper.CreateLiveCarbonIntensity(baseObject);
            Assert.AreEqual(expectedValue, liveCarbonIntensity.lc_rollingMeanCarbonIntensity);
        }

    }
}
